#pragma once
#ifndef EVENTLOOPTHREAD_H
#define EVENTLOOPTHREAD_H
#include "NonCopyable.h"
#include <functional>
#include "EventLoop.h"
#include <string>
#include <mutex>
#include <condition_variable>
#include "Thread.h"
namespace mymuduo {

class EventLoopThread : NonCopyable {

public:
    using ThreadInitCallback = std::function<void(EventLoop*)>;
    EventLoopThread(const ThreadInitCallback &cb = ThreadInitCallback(),
                    const std::string &name = std::string() );
    ~EventLoopThread();

    EventLoop* startLoop();

private:
    void threadFunc();

    EventLoop *loop_;
    bool exiting_;
    Thread thread_;
    std::mutex mutex_;
    std::condition_variable cond_;
    ThreadInitCallback callback_;
};

}

#endif